<template>
  <div>
    <zh-form ref="formInfo"  :rules="rules" :model="formData"  labelAlign="right" >

      <zh-card style="width:100%;float:left">

        <zh-row :span="18">
          <zh-input
              v-if="type === '0'"
              prop="orgId"
              type="select"
              :options="orgList"
              :defaultFields="{ label: 'dictValue', value: 'dictKey' }"
              label="区划"
              v-model="formData.orgId"
          ></zh-input>
          <zh-input
              v-if="type === '0'"
              prop="h1402"
              type="text"
              label="推广次数"
              v-model="formData.h1402"
          ></zh-input>

          <zh-input
              v-if="type === '1'"
              prop="h1403"
              type="text"
              label="景区名称"
              v-model="formData.h1403"
          ></zh-input>
          <zh-input
              v-if="type === '1'"
              prop="h1404"
              type="text"
              label="收益(万元)"
              v-model="formData.h1404"
          ></zh-input>
          <zh-input
              v-if="type === '1'"
              prop="h1405"
              type="select"
              :options="dictData.H1405"
              :defaultFields="{ label: 'dictValue', value: 'dictKey' }"
              label="业态发展评价"
              v-model="formData.h1405"
          ></zh-input>

          <zh-input type="month" :disabled="false" label="年月:" v-model="formData.h1406" format="YYYY-MM"/>

        </zh-row>
        <div style="height: 50px">

        </div>
      </zh-card>
    </zh-form>
  </div>
</template>

<script>
import {getOrgList} from "@/services/system/whdngxlApi";
import {getBatchDict} from "@/services/system/api";
import UnmovableRelics from "@/pages/whdngxl/TasksCheckManage/UnmovableRelics";

export default {
  name: "benefitEvaluationForm",
  props: {
    type: {
      type: String,
      default: () => null,
    },
  },
  data(){
    return {
      orgList: [],
      formData: {
        h1401: undefined,
        orgId: undefined,
        orgName: undefined,
        h1402: undefined,
        h1403: undefined,
        h1404: undefined,
        h1405: undefined,
        h1406: undefined,
        type: this.type
      },
      dictData: {

      }
    }
  },
  created() {
    this.$http.post(getOrgList, {}).then((res) => {
      this.orgList = res.result;
    });
    this.$http.post(getBatchDict, {dictFields: 'H1405'}).then((res) => {
      this.dictData = res.result;
    });
  },
  methods: {
    initData(row){
      this.formData = row
    },
    getHandleData(){
      return this.formData
    }
  },
  watch: {
    'formData.orgId': {
      handler() {
        if(this.formData.orgId === undefined){
          this.formData.orgName = undefined
        }else {
          this.orgList.forEach(item =>{
            if(item.dictKey === this.formData.orgId){
              this.formData.orgName = item.dictValue
            }
          })
        }
      },
      immediate: true,
      deep: true
    }
  }
}
</script>

<style scoped>

</style>